﻿using System;
using System.Collections.Generic;

namespace Beeflys.Generator
{
    public sealed class Filter
    {
        public static (List<UTypeInfo> protocols, List<UTypeInfo> messengers, List<Error> errors) Start()
        {
            var types = Mapper.Types;
            var sourceList = new List<UTypeInfo>();
            foreach (var type in types)
            {
                if (type.IsSource) sourceList.Add(type);
            }

            var pItems = Protocol.Start(sourceList);
            if (pItems.Item2.Count > 0)
            {
                return (null, null, pItems.Item2);
            }

            var mItems = Messenger.Start(sourceList);
            if (mItems.Item2.Count > 0)
            {
                return (null, null, mItems.Item2);
            }

            return (pItems.Item1, mItems.Item1, null);
        }
    }
}